package tiltmaze.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BoxLayout;
import javax.swing.ButtonGroup;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

/**
 * Frame with the selection of fitness function.
 * @author Juraj Niznan
 */
public class SettingsManager {

    private int fitNum = 0;
    JPanel panel;

    public SettingsManager() {
        this.panel = new JPanel();
        this.panel.setLayout(new BoxLayout(panel, BoxLayout.LINE_AXIS));

        JPanel panelInside = new JPanel();
        panelInside.setLayout(new BoxLayout(panelInside, BoxLayout.Y_AXIS));

        JLabel label = new JLabel("Select fitness function:");
        panelInside.add(label);

        ButtonGroup btnGroup = new ButtonGroup();

        JRadioButton fit0 = new JRadioButton("relative_edge_deadlocks * shortest_solution_length");
        fit0.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                fitNum = 0;
            }
        });
        btnGroup.add(fit0);
        panelInside.add(fit0);
        fit0.setSelected(true);

        JRadioButton fit1 = new JRadioButton("shortest_solution_length + 0,1 * longest_solution_length");
        fit1.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                fitNum = 1;
            }
        });
        btnGroup.add(fit1);
        panelInside.add(fit1);

        JRadioButton fit2 = new JRadioButton("number of edges in state graph");
        fit2.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                fitNum = 2;
            }
        });
        btnGroup.add(fit2);
        panelInside.add(fit2);

        this.panel.add(panelInside);


    }

    public int getFitNum() {
        return fitNum;
    }
}
